home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 October: Technology Seed / ADC Seed CD - October 1999.toast / FireWire / FireWire_2.1_SDK_DR3 / Source / FWiX / FWiXFamily / FWiXExpert.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-17  |  4.2 KB  |  175 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        FWiXExpert.c
  3.  
  4.     Contains:    Code to implement FireWire File Exchange driver expert loader.
  5.  
  6.     Version:    1.0
  7.  
  8.     Written by:    Jay Lloyd
  9.  
  10.     Copyright:    © 1996-1999 by Apple Computer, Inc., all rights reserved.
  11.  
  12.     File Ownership:
  13.  
  14.         DRI:                Jay Lloyd
  15.  
  16.         Other Contact:        
  17.  
  18.         Technology:            FireWire
  19.  
  20.     Writers:
  21.  
  22.         (JRH)    Rhoads Hollowell
  23.         (jkl)    Jay Lloyd
  24.  
  25.     Change History (most recent first):
  26.  
  27.        <FW6>      4/8/99    jkl        Converted to use GDF services.
  28.        <FW5>     2/26/98    JRH        Include DriverFamilyMatchingPriv.h
  29.        <FW4>     11/4/97    jkl        Deglommed fwix.
  30.        <FW3>    12/27/96    ES        Took out some DebugStrs.
  31.        <FW2>    12/20/96    GG        Removed FWXExpertTerminate routine and all references to
  32.                                     FWiXFamily. Added loading of FWiXFamily nlib and FWXScanner Code
  33.                                     fragment for glom implementation. also added internal routine
  34.                                     FindExpertFSSpec.
  35.        <FW1>     10/2/96    jkl        initial check-in, copied from avt family
  36.  
  37. */
  38.  
  39. #include <Types.h>
  40. #include <Files.h>
  41. #include <Folders.h>
  42. #include "GenericDriverFamily.h"
  43.  
  44. #include "FWiX.h"
  45. #include "FWiXExpert.h"
  46.  
  47. GDFDeviceEventRegistrationID    gGDFDeviceEventRegistrationID = kInvalidGDFDeviceEventRegistrationID;
  48. FSSpec                            gThisFragSpec;
  49.  
  50. ////////////////////////////////////////////////////////////////////////////////
  51. //
  52. // The service descriptor.
  53. //
  54.  
  55. GDFServiceDescription             TheGDFServiceDescription =
  56. {
  57.     kGDFServiceDescriptionSignature,
  58.     kInitialGDFServiceDescriptor,
  59.     {
  60.         kServiceCategoryFWiX,
  61.         1, 0, finalStage, 1,
  62.         0
  63.     },
  64.     {
  65.         kGDFServiceIsLoadedUponDiscovery,
  66.         "\pFWiX",
  67.         { 0, 0, 0, 0, 0, 0, 0, 0 }
  68.     }
  69. };
  70.  
  71.  
  72. ////////////////////////////////////////////////////////////////////////////////
  73. ////////////////////////////////////////////////////////////////////////////////
  74. //
  75. // Private routines.
  76. //
  77. ////////////////////////////////////////////////////////////////////////////////
  78. ////////////////////////////////////////////////////////////////////////////////
  79.  
  80. ////////////////////////////////////////////////////////////////////////////////
  81. //
  82. // ExpertEntryPoint
  83. //
  84. //   This routine installs the FireWire File Exchange driver expert loader.
  85. //
  86.  
  87. long ExpertEntryPoint(void)
  88. {
  89.     CInfoPBRec                catInfoPB;
  90.     Str63                    fileName;
  91.     UInt32                    eventTable[1];
  92.     SInt32                    extfDirID;
  93.     OSStatus                status = noErr;
  94.     SInt16                    extfIndex = 1;
  95.     SInt16                    extfVRefNum;
  96.  
  97.     // get the extensions folder
  98.     status = FindFolder(kOnSystemDisk, kExtensionFolderType, kDontCreateFolder,
  99.                         &extfVRefNum, &extfDirID);
  100.     
  101.     // locate this file and create file spec
  102.     if (status == noErr)
  103.     {
  104.         while (status == noErr)
  105.         {
  106.             fileName[ 0 ]                    = '\0';
  107.             fileName[ 1 ]                    = '\0';
  108.             catInfoPB.hFileInfo.ioNamePtr    = &fileName[0];
  109.             catInfoPB.hFileInfo.ioVRefNum    = extfVRefNum;
  110.             catInfoPB.hFileInfo.ioFDirIndex    = extfIndex++;
  111.             catInfoPB.hFileInfo.ioDirID        = extfDirID;
  112.             
  113.             status = PBGetCatInfoSync(&catInfoPB);
  114.             if (status == noErr)
  115.             {
  116.                 if ((catInfoPB.hFileInfo.ioFlFndrInfo.fdType == 'expt') &&
  117.                     (catInfoPB.hFileInfo.ioFlFndrInfo.fdCreator == 'FWiX'))
  118.                 {
  119.                     status = FSMakeFSSpec(extfVRefNum, extfDirID, catInfoPB.hFileInfo.ioNamePtr, &gThisFragSpec);
  120.                     break;
  121.                 }                
  122.             }
  123.         }
  124.     }
  125.  
  126.     // register file with GDF services
  127.     if (status == noErr)
  128.         status = GDFRegisterFSSpecExpert(&gThisFragSpec);
  129.         
  130.     // Register to receive generic device added events.
  131.     if (status == noErr)
  132.     {
  133.         eventTable[0] = kGDFDeviceAddedEvent;
  134.         eventTable[1] = kGDFDeviceRemovedEvent;
  135.         status = GDFRegisterDeviceEventHandlerProc(
  136.                     kServiceCategoryFWiX, 2, &eventTable[0],
  137.                     FWXDeviceNotificationHandler, nil,
  138.                     &gGDFDeviceEventRegistrationID);
  139.     }
  140.  
  141.     return status;
  142. }
  143.  
  144.  
  145. ////////////////////////////////////////////////////////////////////////////////
  146. //
  147. // FWXExpertTerminate
  148. //
  149. //   This proc terminates the FireWire File Exchange driver expert loader.
  150. //
  151.  
  152. long FWXExpertTerminate()
  153. {
  154.     OSStatus    status = noErr;
  155.  
  156.     // Unregister with Generic Device family.
  157.     if (gGDFDeviceEventRegistrationID != kInvalidGDFDeviceEventRegistrationID)
  158.         status = GDFUnregisterDeviceEventHandler(gGDFDeviceEventRegistrationID);
  159.     
  160.     return status;
  161. }
  162.  
  163.  
  164. ////////////////////////////////////////////////////////////////////////////////
  165. //
  166. // GDFExpertEntryPoint
  167. //
  168. // Initialize the family.
  169. //
  170.  
  171. long GDFExpertEntryPoint(void)
  172. {
  173.     return ((long) InitializeFWXFamily ());
  174. }
  175.